﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
struct UserInfo
{
    public string UserName { get; private set; }
    public int Age { get; private set; }
    public FitnessGoal FitnessGoal;
    public double Weight { get; private set; }
    public double Height { get; private set; }
    public bool IsMale { get; private set; }
    public bool IsVegetarian { get; private set; }

    public UserInfo(string path)
        : this(Helpers.ReadFile(path)) {



    }

    public UserInfo(Dictionary<string, string> dict)
        : this() {
        this.UserName = dict["name"];
        this.Age = int.Parse(dict["age"]);
        this.FitnessGoal = (FitnessGoal)Enum.Parse(typeof(FitnessGoal), dict["fitness-goal"], true);
        this.Weight = double.Parse(dict["weight"]);
        this.Height = double.Parse(dict["height"]);
        this.IsMale = Helpers.ToBool(dict["ismale"]);
        if(dict.ContainsKey("isvegetarian"))
            this.IsVegetarian = Helpers.ToBool(dict["isvegetarian"]);
    }
    public void WriteToFile(string path)
    {
        StreamWriter streamWriter = new StreamWriter(path);
        using (streamWriter)
        {
            streamWriter.WriteLine("Name=" + this.UserName);
            streamWriter.WriteLine("age=" + Convert.ToString(this.Age));
            streamWriter.WriteLine("fitness-goal=" + Convert.ToString(this.FitnessGoal));
            streamWriter.WriteLine("Weight=" + Convert.ToString(this.Weight));
            streamWriter.WriteLine("Height=" + Convert.ToString(this.Height));
            streamWriter.WriteLine("isMale=" + Convert.ToString(this.IsMale));
            streamWriter.WriteLine("isVegetarian=" + Convert.ToString(this.IsVegetarian));
        }
    }

}
